package Demo4;
//实现多个接口
//Java是单继承，只能有一个父类，但是可以实现多个接口
//java语法要求先继承，再实现，多实现通过，分隔开多个接口
//接口撇开了类型，只需要满足某种功能或者规范就可以动态绑定
//继承表示的是is a的关系，但是接口
//继承表达的含义是 is - a 语义, 而接口表达的含义是 具有 xxx 特性 .
//        猫是一种动物, 具有会跑的特性.
//        青蛙也是一种动物, 既能跑, 也能游泳
//        鸭子也是一种动物, 既能跑, 也能游, 还能飞


//实现不同接口，但是这两个接口都有同名的方法，编译器无法识别
//interface A{
//    void func();
//}
//interface B{
//    void func();
//}
//class C implements A,B{
//    public void func() {
//
//    }
//}


public class Test {
    public static void walk(IRunning iRunning) {
        iRunning.run();
    }

    public static void flying(IFly iFly) {
        iFly.fly();
    }

    public static void swim(ISwimming iSwimming) {
        iSwimming.swim();
    }
    public static void main(String[] args) {
        walk(new Dog("旺财"));
        walk(new Duck("嘎嘎"));
        flying(new Duck("嘎嘎"));
        flying(new Bird("圆圆"));

        swim(new Duck("嘎嘎"));
        swim(new Fish("七秒"));
    }
}
interface IRunning {
    void run();
}

interface ISwimming {
    void swim();
}

interface IFly {
    void fly();
}

abstract class Animal{
    public String name;
    public Animal(String name) {
        this.name = name;
    }
}

class Dog extends Animal implements IRunning  {
    public Dog(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(name + "正在跑");
    }
}

class Fish extends Animal implements ISwimming{
    public Fish(String name) {
        super(name);
    }

    @Override
    public void swim() {
        System.out.println(name + "在游泳");
    }
}

class Bird extends Animal implements IFly{
    public Bird(String name) {
        super(name);
    }
    public void  fly() {
        System.out.println(name + "正在飞");
    }
}

class Duck extends Animal implements IRunning,ISwimming,IFly{
    public Duck(String name) {
        super(name);
    }

    public void run() {
        System.out.println(name + "正在跑");
    }

    public void swim() {
        System.out.println(name + "🏊‍");
    }

    public void fly() {
        System.out.println(name + "飞");
    }
}

class Robot implements IRunning,ISwimming,IFly{

    @Override
    public void run() {
        System.out.println("跑");
    }

    @Override
    public void swim() {

    }

    @Override
    public void fly() {

    }
}